<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="public/css/public.css"/>
<style type="text/css">

#upload a{display:block;float:right;margin:4px;}
#upload span{display:block;width:100px;float:left;font-size:12px;font-weight:bold;}
#upload li{float:left;width:700px;}
.submit{width:700px;clear:both;padding-left:100px;}
</style>
</head>
<body>
	<!--miniHeader{{{-->
	<div class="s_miniHeader">
		<div class="headerBox">
			<div class="logo"><div style="padding:3px 0 0 0;"><a href="/"><img src="public/img/logo.png"/></a></div></div>
			<div class="nav">
				<?php include 'part/miniHeader.tpl.php'; ?>
			</div>
		</div>
	</div>
	<!--}}}-->

	<div class="s_main col2_21">
		<?php include 'part/left.tpl.php'; ?>

		<!--right{{{-->
		<div class="right">
			<div class="box fl" style="width:720px;">
				<div class="head">
					<div class="caption">
					<div class="title"><?php echo $title; ?></div>
					</div>
				</div>
				<div class="body">
					<form action="?m=admin&c=article&a=addPic" method="post"  enctype="multipart/form-data">
						<?php
							if(isset($id)){
								echo '<input type="hidden" name="id" value="'.$data['id'].'"/>';
							}
						?>
						<ul id="upload">
						<li><span>标题:</span><input size="50" type="text" name="title" value="<?php echo isset($data['title'])?$data['title']:''; ?>"/></li>
							<li>
								<span>选择分类:</span>
								<select name="category">
								<?php
									if(!empty($categorys)){
										foreach($categorys as $category){
											echo "<option value='".$category['id']."' style='width:300px;'>".$category['name']."</option>";
										}
									}
								?>
								</select>
							</li>
							<?php
								if(isset($id) && isset($data['original_uploadfile'])){
									$files = json_decode($data['original_uploadfile']);
									$uploadfile= json_decode($data['uploadfile']);
									foreach($files as $k=>$file){
										echo "<li><span>源文件:</span><a href='/upload/{$uploadfile[$k]}' style='float:left;' target='_blank'><img src='/upload/{$uploadfile[$k]}' width='50' height='50'/></a><b style='display:none'>{$uploadfile[$k]}</b><a href='javascript:;' onclick='addElement()'>添加</a><a href='javascript:;' onclick='javascript:removeElement($(this));'>删除</a></li>";
									}
								}else{
							?>
									<li><span>上传文件:</span><input size="50" type="file" name="userfile[]"/><a href="javascript:;" onclick="addElement()">添加</a></li>
							<?php
								}
							?>
								<li><span>内容:</span><?php $FCKeditor->Create(); ?></li>
						</ul>
						<div class="submit"><input type="submit" value="<?php echo !isset($id)?'添加':'修改';?>" class="btn"/></div>
					</form>
				</div>
			</div>
		</div>
		<!--}}}-->
	</div>
</body>
</html>
<script type="text/javascript" src="syntaxhighlighter/syntaxhighlighter.js"></script>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = 'syntaxhighlighter/scripts/clipboard.swf';
</script>
<script type="text/javascript" src="public/js/jquery-1.6.js"></script>
<script type="text/javascript">
function addElement(){
	var html=	'<li><span>上传文件:</span><input type="file" size="50" name="userfile[]"/><a href="javascript:;" onclick="addElement()">添加</a><a href="javascript:;" onclick="javascript:$(this).parent().remove();">移除</a></li>';
	$('#upload').append(html);
}

function removeElement(o){
	var  p= o.parent();
	var uploadfile = p.children('b').html();
	var u = '?m=admin&c=article&a=removeAttachment&uploadfile='+uploadfile+"&id="+<?php echo isset($id)?$id:0; ?>;
	var i=new Image(); i.src=u; i.onerror=function(){};
	p.remove();
}
</script>
